Skip to content

feat(buffers): default to ArrayPool.Shared with STArrayPool as single-thread opt-in#62

Merged
tgiachi merged 1 commit into
developfrom
feature/arraypool-default-flip
Jul 4, 2026
Merged

feat(buffers): default to ArrayPool.Shared with STArrayPool as single-thread opt-in#62
tgiachi merged 1 commit into
developfrom
feature/arraypool-default-flip

Conversation

@tgiachi

@tgiachi tgiachi commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Thread-safe by default: ValueStringBuilder constructors and Create now default to mt: true (BCL ArrayPool<char>.Shared); mt: false is the explicit opt-in to the single-threaded STArrayPool<char>.Shared for hot paths.
  • RawInterpolatedStringHandler, PooledArraySpanFormattable, StringHelpers.Remove and ToPooledArray now rent from and return to ArrayPool<char>.Shared (pool pairing traced end to end: every Rent returns to the pool it came from, including the handler buffer recycled through ValueStringBuilder.Append).
  • ToPooledArray caller contract updated: return via ArrayPool<char>.Shared.Return(array).
  • Docs article "Buffers and pooled strings" decision table and examples aligned; STArrayPool itself is unchanged and still available for direct use.

Test plan

  • Full suite green: 1145/1145
  • Release build of SquidStd.Core clean (XML doc validation)
  • Opt-in path covered by new SingleThreadedMode_UsesSTArrayPoolAndRoundTrips test

…-thread opt-in

ValueStringBuilder now defaults to mt: true (thread-safe BCL pool);
RawInterpolatedStringHandler, PooledArraySpanFormattable, StringHelpers.Remove
and ToPooledArray rent from ArrayPool<char>.Shared. STArrayPool stays as the
explicit opt-in for single-threaded hot paths. Docs and tests aligned.
@tgiachi
tgiachi merged commit b8fb09b into develop Jul 4, 2026
3 checks passed
@tgiachi
tgiachi deleted the feature/arraypool-default-flip branch July 4, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant